import { Api } from '/@/api/url'
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

export const getAgreement = (params) => {
  return defHttp.get({url : Api.getAgreement, params});
}

export const pageAgreement = (params) => {
  return defHttp.get({url : Api.pageAgreement, params});
}

export const saveOrUpdateAgreement = (params, isUpdate) => {
  let url = isUpdate ? Api.updateAgreement : Api.saveAgreement;
  return defHttp.post({url: url, params});
}

export const deleteAgreement = (params, handleSuccess) => {
  return defHttp.delete({url: Api.deleteAgreement, data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const batchDeleteAgreement = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchDeleteAgreement, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}


